package com.haixee.parkdemo.common.exception;


import com.haixee.parkdemo.common.response.ResultPort;
import org.springframework.http.HttpStatus;

/**
 * 业务异常
 *
 * @author GUIFENG GUO
 * 2020/3/22 8:17
 */
public class BusinessException extends RuntimeException {

    private final Integer code;

    private final HttpStatus status;

    public BusinessException(HttpStatus status, ResultPort resultEnum, String message) {
        super(message);
        this.code = resultEnum.getCode();
        this.status = status;
    }

    public BusinessException(HttpStatus status, Integer code, String message) {
        super(message);
        this.code = code;
        this.status = status;
    }

    public BusinessException(ResultPort resultEnum, String message) {
        this(HttpStatus.OK, resultEnum, message);
    }

    public BusinessException(HttpStatus status, ResultPort resultEnum) {
        this(status, resultEnum, resultEnum.getMsg());
    }

    public BusinessException(ResultPort resultEnum) {
        this(resultEnum, resultEnum.getMsg());
    }

    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }

    public HttpStatus getStatus() {
        return status;
    }

}
